# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=forgejo-runner
pkgver=3.4.1
pkgrel=1
pkgdesc="CI/CD job runner for Forgejo"
url="https://code.forgejo.org/forgejo/runner"
arch="all"
license="MIT"
makedepends="go"
install="$pkgname.pre-install $pkgname.pre-upgrade"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://codeberg.org/forgejo/runner/archive/v$pkgver.tar.gz

	forgejo-runner.logrotate
	forgejo-runner.initd
	forgejo-runner.confd
	"
builddir="$srcdir/runner"
options="!check" # tests require running forgejo

build() {
	go build \
		-o forgejo-runner \
		-ldflags "-X gitea.com/gitea/act_runner/internal/pkg/ver.version=$pkgver"
	./forgejo-runner generate-config > config.example.yaml
}

check() {
	go test ./...
}

package() {
	install -Dm755 forgejo-runner -t "$pkgdir"/usr/bin/
	install -Dm644 config.example.yaml -t "$pkgdir"/etc/forgejo-runner/

	install -Dm755 "$srcdir"/forgejo-runner.initd "$pkgdir"/etc/init.d/forgejo-runner
	install -Dm644 "$srcdir"/forgejo-runner.confd "$pkgdir"/etc/conf.d/forgejo-runner
	install -Dm644 "$srcdir"/forgejo-runner.logrotate "$pkgdir"/etc/logrotate.d/forgejo-runner
}

sha512sums="
aea401ddb8359bc91a4c24ca5b14bcf01ac74480405deac153ecd83cb69454456353b9c4468c29380d52289a1743accad5642c4fa1609fd854fe459e2da7fe3a  forgejo-runner-3.4.1.tar.gz
a3c7238b0c63053325d31e09277edd88690ef5260854517f82d9042d6173fb5d24ebfe36e1d7363673dd8801972638a6e69b6af8ad43debb6057515c73655236  forgejo-runner.logrotate
bb0c6fbe90109c77f9ef9cb0d35d20b8033be0e4b7a60839b596aa5528dfa24309ec894d8c04066bf8fb30143e63a5fd8cc6fc89aac364422b583e0f840e2da6  forgejo-runner.initd
e11eab27f88f1181112389befa7de3aa0bac7c26841861918707ede53335535425c805e6682e25704e9c8a6aecba3dc13e20900a99df1183762b012b62f26d5f  forgejo-runner.confd
"
